package com.wyix.sercvice.impl;

import com.wyix.entity.AbstractUser;
import com.wyix.entity.Order;
import com.wyix.sercvice.RiderService;

/**
 * 具体骑手类：实现骑手接口 + 继承抽象用户类
 *
 * @author wangdx
 * @since 2025/8/1
 */
public class FullTimeRider extends AbstractUser implements RiderService {
    private double rating; // 骑手评分（特有属性）

    public FullTimeRider(String userId, String name) {
        super(userId, name);
        this.rating = 4.8; // 默认评分
    }

    // 实现骑手接口的"取餐"方法
    @Override
    public void pickupMeal(Order order) {
        if (!isOnline) {
            throw new IllegalStateException("骑手[" + name + "]未登录，无法取餐");
        }
        System.out.println("骑手[" + name + "]取餐：订单" + order.getId() + "（当前评分：" + rating + "）");
        order.setStatus("已取餐");
    }

    // 实现骑手接口的"送餐"方法
    @Override
    public void deliverMeal(Order order) {
        System.out.println("骑手[" + name + "]送餐到：" + order.getAddress() + "（订单" + order.getId() + "）");
        order.setStatus("已送达");
        rating += 0.1; // 完成订单后评分提升
    }

    @Override
    public String getRoleDesc() {
        return "全职骑手：ID=" + userId + "，姓名=" + name + "，评分=" + rating;
    }
}